package com.example.springboot_sp.common;

public class ResultBlog<T> {
    private String code;
    private String msg;
    private T data;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public ResultBlog() {
    }

    public ResultBlog(T data) {
        this.data = data;
    }

    public static ResultBlog success() {
        ResultBlog result = new ResultBlog<>();
        result.setCode("0");
        result.setMsg("成功");
        return result;
    }

    public static <T> ResultBlog<T> success(T data) {
        ResultBlog<T> result = new ResultBlog<>(data);
        result.setCode("0");
        result.setMsg("成功");
        return result;
    }

    public static ResultBlog error(String code, String msg) {
        ResultBlog result = new ResultBlog();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }
}
